/*
 * @Author Baorong Yu
 * @Email: y15195965752@163.com
 * @Address: 杭州市余杭区赛银国际12幢4楼
 * @Date 2022-07-27 16:22:00 Wednesday
 * description: 进步器
 */

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_uikit/flutter_uikit.dart';

class UIStepper extends StatelessWidget {
  final int number;
  final double numberFontSize;
  final double width;
  final double height;
  final int bgColor;
  final double fontSize;
  final int buttonColor;
  final double radius;
  final bool isOutLine;
  final Function() add;
  final Function() cut;

  const UIStepper({
    Key? key,
    required this.number,
    required this.add,
    required this.cut,
    this.numberFontSize = 14,
    this.width = 28,
    this.height = 28,
    this.bgColor = 0xFFF5F5F5,
    this.fontSize = 20,
    this.buttonColor = 0xFF000000,
    this.radius = 6,
    this.isOutLine = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: this.isOutLine
          ? BoxDecoration(
              border: Border.all(width: 1, color: Color(0xFFEFEFEF)),
              borderRadius: BorderRadius.circular(this.radius))
          : null,
      child: Row(
        children: <Widget>[
          Container(
            width: this.width,
            height: this.height,
            child: UIButton(
              onPressed: this.cut,
              radius: this.radius,
              color: this.isOutLine ? 0x00 : this.bgColor,
              buttonState: UIButtonState(
                  title: '-', fontSize: this.fontSize, color: this.buttonColor),
            ),
          ),
          Container(
            width: this.width * 1.5,
            height: this.height,
            alignment: Alignment.center,
            child: UIText(
              textAlign: TextAlign.center,
              data: this.number.toString(),
              fontSize: this.numberFontSize,
            ),
          ),
          Container(
            width: this.height,
            height: this.height,
            child: UIButton(
              onPressed: this.add,
              radius: this.radius,
              color: this.isOutLine ? 0x00 : this.bgColor,
              buttonState: UIButtonState(
                  title: '+', fontSize: this.fontSize, color: this.buttonColor),
            ),
          ),
        ],
      ),
    );
  }
}
